---
title: Configuration.replaceStreamEnd()
api: Configuration.replaceStreamEnd
---

## Description

<Summary/>

<FilterDiagram
  name="replaceStreamEnd"
  input="Event"
  output="Event"
/>

The user function will receive as parameter a [StreamEnd](/reference/api/StreamEnd) event that is removed from the input stream. Whatever the function returns will be inserted into the output stream in place of the removed event. It can be an event or a [Message](/reference/api/Message), or an array of events or _Messages_. If the function returns nothing (_null_ or _undefined_), no events will be inserted back into the stream.

You can also use a fixed replacement value instead of a function if the replacement is static.

## Syntax

``` js
pipy()
  .pipeline()
  .replaceStreamEnd(
    event => transform(event)
  )
```

## Parameters

<Parameters/>

## See Also

* [Configuration](/reference/api/Configuration)
* [replaceStreamStart()](/reference/api/Configuration/replaceStreamStart)
* [replaceMessageStart()](/reference/api/Configuration/replaceMessageStart)
* [replaceMessageBody()](/reference/api/Configuration/replaceMessageBody)
* [replaceMessageEnd()](/reference/api/Configuration/replaceMessageEnd)
* [replaceMessage()](/reference/api/Configuration/replaceMessage)
* [replaceData()](/reference/api/Configuration/replaceData)
